package com.yjsn.base.exception;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;

/**
 * @comment 第三方请求异常
 * @Author
 */
public class RestThirdException extends RuntimeException {
    private String url;
    private HttpHeaders httpHeaders;
    private Object body;
    private Integer statusCode;
    private String reasonPhrase;
    private String method;

    public RestThirdException() {
        super();
    }

    public RestThirdException(String message) {
        super(message);
    }
    public RestThirdException(String method, String url, HttpStatus httpStatus) {
        super("第三方接口请求异常: " + httpStatus.value() + " " + httpStatus.getReasonPhrase());
        this.method = method;
        this.url = url;
        this.statusCode = httpStatus.value();
        this.reasonPhrase = httpStatus.getReasonPhrase();
    }

    public RestThirdException(String method, String url, HttpHeaders httpHeaders, HttpStatus httpStatus) {
        this(method, url, httpStatus);
        this.httpHeaders = httpHeaders;
    }

    public RestThirdException(String method, String url, Object body, HttpStatus httpStatus) {
        this(method, url, httpStatus);
        this.body = body;
    }

    public RestThirdException(String method, String url, HttpHeaders httpHeaders, Object body, HttpStatus httpStatus) {
        this(method, url, httpHeaders, httpStatus);
        this.body = body;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public HttpHeaders getHttpHeaders() {
        return httpHeaders;
    }

    public void setHttpHeaders(HttpHeaders httpHeaders) {
        this.httpHeaders = httpHeaders;
    }

    public Object getBody() {
        return body;
    }

    public void setBody(Object body) {
        this.body = body;
    }

    public Integer getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Integer statusCode) {
        this.statusCode = statusCode;
    }

    public String getReasonPhrase() {
        return reasonPhrase;
    }

    public void setReasonPhrase(String reasonPhrase) {
        this.reasonPhrase = reasonPhrase;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }
}
